/**============================================================================
 Confidential Information - Limited distribution to authorized persons only.
 This software is protected as an unpublished work under the U.S. Copyright
 Act of 1976.

 Copyright (c) 2011, BluePhoenix Solutions, Inc. All rights reserved.
 ----------------------------------------------------------------------------
 file......: Tag.java
 Author....: Vyacheslav Kovalyov
 Created...: 28.10.11

 Description:

 ============================================================================*/
package ru.monyag.pred.core.tag;

/**
 * @author Vyacheslav Kovalyov
 * @version 1.0
 */
public class Tag implements Comparable<Tag> {

    public Tag(String text, int count) {
        this.text = text;
        this.count = count;
    }

    public String getText() {
        return text;
    }

    public int getCount() {
        return count;
    }

    @Override
    public int compareTo(Tag o) {
        int anotherVal = o.getCount();
        return (count < anotherVal ? -1 : (count == anotherVal ? 0 : 1));
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Tag tag = (Tag) o;

        if (text != null ? !text.toLowerCase().equals(tag.text.toLowerCase()) : tag.text != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return text != null ? text.toLowerCase().hashCode() : 0;
    }

    private final String text;
    private final int count;
}
